/**
 * @Title: UserInfo.java
 * @Package com.zll.ccp.service.impl
 * @author zhanglinlu
 * @date 2019年5月2日 下午1:12:01
 */
package com.zll.ccp.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zll.ccp.mapper.IUserInfoMapper;
import com.zll.ccp.mapper.IUserMapper;
import com.zll.ccp.model.UserInfo;
import com.zll.ccp.service.IUserInfoService;

/**
 * @ClassName: UserInfo
 * @Description: 用户详情实现类
 * @author zhanglinlu
 * @date 2019年5月2日 下午1:12:01
 * 
 */
@Service
@Transactional
public class UserInfoServiceImpl implements IUserInfoService {

    @Autowired
    private IUserInfoMapper userInfoMapper;

    @Autowired
    private IUserMapper IUserMapper;

    /* (non-Javadoc)
     * @param userName
     * @return
     * @see com.zll.ccp.service.IUserInfoService#getUserInfoByUserName(java.lang.String)
     */
    @Override
    public UserInfo getUserInfoByUserName(String userName) {
        UserInfo userInfo = userInfoMapper.getUserInfoByUserName(userName);
        if (userInfo == null) {
            userInfo = new UserInfo();
            userInfo.setUserName(userName);
        }
        return userInfo;
    }

    /* (non-Javadoc)
     * @param userInfo
     * @see com.zll.ccp.service.IUserInfoService#addUserInfo(com.zll.ccp.model.UserInfo)
     */
    @Override
    public void addUserInfo(UserInfo userInfo) {
        userInfoMapper.addUserInfo(userInfo);
    }

    /* (non-Javadoc)
     * @param userInfo
     * @see com.zll.ccp.service.IUserInfoService#updateUserInfoById(com.zll.ccp.model.UserInfo)
     */
    @Override
    public void updateUserInfoById(UserInfo userInfo) {
        userInfoMapper.updateUserInfoById(userInfo);
    }

    /* (non-Javadoc)
     * @param newUserName
     * @param oldUserName
     * @see com.zll.ccp.service.IUserInfoService#updateUserNameByUserNamme(java.lang.String, java.lang.String)
     */
    @Override
    public void updateUserNameByUserNamme(String newUserName, String oldUserName) {
        IUserMapper.updateUserNameByUserNamme(newUserName, oldUserName);
    }

}
